import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { SelectionFactor } from './transfer.interface';

@Injectable()
export class TransferService {
  parentComponent;

  selectionChange$ = new Subject<{ [key: string]: any }>();

  getParentComponent(): any {
    return this.parentComponent;
  }

  /**
   * parent
   */
  setParentComponent(component): void {
    this.parentComponent = component;
  }

  getSelectionStream(): Observable<any> {
    return this.selectionChange$.asObservable();
  }

  setSelectionStream(source: SelectionFactor): void {
    this.selectionChange$.next(source);
  }
}
